var express = require("express");
// 引用数据

var app = express();
app.use(function (req, res, next) {
    res.header('Access-Control-Allow-Origin', '*');

    res.header('Access-Control-Allow-Headers', 'Content-Type,Content-Length, Authorization, Accept, X-Requested-With , yourHeaderFeild');

    res.header('Access-Control-Allow-Methods', 'PUT, POST, GET, DELETE,OPTIONS');

    next();
})
app.get("/login", function (req, res) {
    if (req.query.uname == "user") {
        // 如果用户名是user那么就是普通用户
        let routerdata = [
            {
                path: 'shouye',
                name: 'shouye',
                demo: 'rrk/ShouyeView.vue',
                meta: {
                    title: "用户a"
                }
            },
            {
                path: 'userb',
                name: 'shop',
                demo: 'user/userb.vue',
                meta: {
                    title: "用户b"
                }
            },
            {
                path: 'userc',
                name: 'up',
                demo: 'user/userc.vue',
                meta: {
                    title: "用户c"
                }
            },
            {
                path: 'userd',
                name: 'user',
                demo: 'user/userd.vue',
                meta: {
                    title: "用户d"
                }
            }
        ]
        res.send({ msg: "用户", userid: 1, routerdata, token: "我是模拟token" });

    } else if (req.query.uname == "admin") {
        // 如果用户名是admin那么就是管理员用户
        let routerdata = [
            {
                path: 'shouye',
                name: 'guanlia',
                demo: 'rrk/ShouyeView.vue',
                icon: "el-icon-menu",
                meta: {
                    title: "首页"
                }
            },
            {
                path: 'baidumap',
                name: 'baidumap',
                demo: 'rrk/BaiDu.vue',
                icon: "el-icon-s-promotion",
                meta: {
                    title: "地图展示"
                }
            },
            {
                path: 'chakan',
                name: 'chakan',
                demo: 'wyn/ChaKanv.vue',
                icon: "el-icon-view",
                meta: {
                    title: "查看业主信息"
                }
            },
            {
                path: 'xiugai',
                name: 'xiugai',
                demo: 'wyn/XiuGaiv.vue',
                icon: "el-icon-picture-outline-round",
                meta: {
                    title: "宠物信息管理"
                }
            },
            {
                path: 'weixiu',
                name: 'weixiu',
                demo: 'pm/WeiXiu.vue',
                icon: "el-icon-success",
                meta: {
                    title: "已维修订单"
                }
            },
            {
                path: 'nowei',
                name: 'nowei',
                demo: 'pm/NoWei.vue',
                icon: "el-icon-error",
                meta: {
                    title: "未维修订单"
                }
            },
            {
                path: 'PersonFeeManagement',
                name: 'PersonFeeManagement',
                demo: 'fzy/PersonFeeManagement.vue',
                icon: "el-icon-user",
                meta: {
                    title: "物业费管理"
                }
            },
            {
                path: 'WaterChargeManagement',
                name: 'WaterChargeManagement',
                demo: 'fzy/WaterChargeManagement.vue',
                icon: "el-icon-heavy-rain",
                meta: {
                    title: "水费管理"
                }
            },
            {
                path: 'electric',
                name: 'electric',
                demo: 'hhp/ElectricView.vue',
                icon: "el-icon-s-opportunity",
                meta: {
                    title: "电费管理"
                }
            },
            {
                path: 'parking',
                name: 'parking',
                demo: 'hhp/ParkingView.vue',
                icon: "el-icon-truck",
                meta: {
                    title: "停车费管理"
                }
            },
            {
                path: 'worker',
                name: 'worker',
                demo: 'pm/WorkerView.vue',
                icon: "el-icon-s-custom",
                meta: {
                    title: "员工管理"
                }
            },
            {
                path: 'fangwu',
                name: 'fangwu',
                demo: 'lag/FangWuView.vue',
                icon: "el-icon-s-home",
                meta: {
                    title: "房屋管理"
                }
            }
        ]
        res.send({ msg: "管理", userid: 0, routerdata, token: "我是模拟token" });

    } else {
        // 返回用户名密码错误
        res.send({ msg: "用户密码错误", userid: -1, routerdata: [], token: null });
    }

})
app.listen(8899);